<?php
class Filter {

	var $to = "";
	var $from = "";

	function Filter(){
		
	}

	function set_to($to){
		$this->to = $to;
	}

	function set_from($from){
		$this->from = $from;
	}

	function filter_date($field = ""){
		global $from, $to, $dsfm_module;

		$this->from = $from;
		$this->to = $to;

		$filter_date = "";

		if($field == ""){
			$field = $dsfm_module.".add_date";
		}

		if($from != ""){ $filter_date = " and $field > '$from' "; }
		if($to != ""){ 
			$to = date("Y-m-d", strtotime($to)+DAY);
			$filter_date .= " and $field < '$to' ";
		}

		return $filter_date;
	}

	function rain_display($tpl, $template = "filter"){

		$tpl->assign("from", $this->from);
		$tpl->assign("to", $this->to);
		$tpl->draw($template);
	}
}
?>